//
//  PaymentViewController.m
//  gpos_app
//
//  Created by apple on 2018/8/17.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "PaymentViewController.h"
#import "Masonry.h"

@interface PaymentViewController ()<UITextFieldDelegate>
@property (nonatomic,strong)UIView * shuluangView;
@property (nonatomic,strong)UIView * jymimaView;
@property (nonatomic,strong)UIView * yanzhengmaView;
@property (nonatomic,strong)UIView * phoneView;
@property (nonatomic,strong)UITextField * shuliangTextField;
@property (nonatomic,strong)UITextField * jymimaTextField;
@property (nonatomic,strong)UIButton * yanjingButton;
@property (nonatomic,strong)UIButton * yanzhengmaButton;
@property (nonatomic,strong)UITextField * yanzhengmaTextField;

@end

@implementation PaymentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = NO;
    
    self.view.backgroundColor = [UIColor colorWithRed:244/255.0f green:244/255.0f blue:244/255.0f alpha:1];
    self.title = @"生成付款码";
    
    self.shuluangView = [[UIView alloc] init];
    self.shuluangView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.shuluangView];
    if (iPhoneX) {
        [self.shuluangView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view).with.offset(kNavbarHeight+10);
            make.left.equalTo(self.view).with.offset(0);
            make.right.equalTo(self.view).with.offset(0);
            make.height.equalTo(@50);
        }];
        
    }else {
        [self.shuluangView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view).with.offset(74);
            make.left.equalTo(self.view).with.offset(0);
            make.right.equalTo(self.view).with.offset(0);
            make.height.equalTo(@50);
        }];
        
    }
    
    
    self.jymimaView = [[UIView alloc] init];
    self.jymimaView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.jymimaView];
    [self.jymimaView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.shuluangView.mas_bottom).with.offset(1);
        make.left.equalTo(self.view).with.offset(0);
        make.right.equalTo(self.view).with.offset(0);
        make.height.equalTo(@50);
    }];
    
    self.phoneView = [[UIView alloc] init];
    self.phoneView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.phoneView];
    [self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.jymimaView.mas_bottom).with.offset(42);
        make.left.equalTo(self.view).with.offset(0);
        make.right.equalTo(self.view).with.offset(0);
        make.height.equalTo(@50);
    }];
    
    self.yanzhengmaView = [[UIView alloc] init];
    self.yanzhengmaView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.yanzhengmaView];
    [self.yanzhengmaView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.phoneView.mas_bottom).with.offset(1);
        make.left.equalTo(self.view).with.offset(0);
        make.right.equalTo(self.view).with.offset(0);
        make.height.equalTo(@50);
    }];
    
    UILabel * sjNamberlabel = [[UILabel alloc] init];
    sjNamberlabel.text = @"钱包地址";
    sjNamberlabel.textColor = [UIColor grayColor];
    sjNamberlabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:sjNamberlabel];
    [sjNamberlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(15);
        make.top.equalTo(self.jymimaView.mas_bottom).with.offset(12);
    }];
    
    UILabel * sjNbrtextlabel = [[UILabel alloc] init];
    sjNbrtextlabel.textColor = [UIColor grayColor];
    sjNbrtextlabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:sjNbrtextlabel];
    [sjNbrtextlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(sjNamberlabel.mas_right).with.offset(16);
        make.top.equalTo(self.jymimaView.mas_bottom).with.offset(12);
    }];
    
    UILabel * phonelabel = [[UILabel alloc] init];
    phonelabel.text = @"手机号码";
    phonelabel.textColor = [UIColor blackColor];
    phonelabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:phonelabel];
    [phonelabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.phoneView).with.offset(15);
//        make.top.equalTo(self.jymimaView.mas_bottom).with.offset(12);
        make.centerY.equalTo(self.phoneView);
    }];
    
    UILabel * phonetextlabel = [[UILabel alloc] init];
    phonetextlabel.textColor = [UIColor blackColor];
    phonetextlabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:phonetextlabel];
    [phonetextlabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(phonelabel.mas_right).with.offset(16);
        make.centerY.equalTo(self.phoneView);
    }];
    
    UIButton * querenButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:querenButton];
    [querenButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.yanzhengmaView.mas_bottom).with.offset(60);
        make.centerX.equalTo(self.view);
        
    }];
    [querenButton setBackgroundImage:[UIImage imageNamed:@"icon_anniu_f"] forState:UIControlStateNormal];
    querenButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [querenButton setTitle:@"确认" forState:UIControlStateNormal];
    
    [querenButton addTarget:self action:@selector(querenButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    phonetextlabel.text = [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"phoneNumber"]];
    sjNbrtextlabel.text = @"12345678122";
    [self shuliangLoadView];
    [self jymimaLoadView];
    [self yanzhengmaLoadView];
    
    
}

- (void)shuliangLoadView {
    UILabel * shuliangLabel = [[UILabel alloc] init];
    shuliangLabel.text = @"数量";
    shuliangLabel.font = [UIFont systemFontOfSize:14];
    [self.shuluangView addSubview:shuliangLabel];
    [shuliangLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.shuluangView);
        make.left.equalTo(self.shuluangView).with.offset(15);
        make.width.equalTo(@60);
    }];
    
    UILabel * GPOSLabel = [[UILabel alloc] init];
    GPOSLabel.text = @"GPOS";
    GPOSLabel.font = [UIFont systemFontOfSize:14];
    [self.shuluangView addSubview:GPOSLabel];
    [GPOSLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.shuluangView);
        make.width.equalTo(@40);
        make.right.equalTo(self.shuluangView).with.offset(-15);
    }];
    
    self.shuliangTextField = [[UITextField alloc] init];
    [self.shuluangView addSubview:self.shuliangTextField];
    [self.shuliangTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.shuluangView);
        make.left.equalTo(shuliangLabel.mas_right).with.offset(15);
        make.right.equalTo(GPOSLabel.mas_left).with.offset(-15);
        
    }];
    self.shuliangTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.shuliangTextField.placeholder =@"请输入GPOS数量";
    self.shuliangTextField.font = [UIFont systemFontOfSize:14.f];
    
    
    
}

- (void)jymimaLoadView {
    
    UILabel * jymiomaLabel = [[UILabel alloc] init];
    jymiomaLabel.text = @"交易密码";
    jymiomaLabel.font = [UIFont systemFontOfSize:14];
    [self.jymimaView addSubview:jymiomaLabel];
    [jymiomaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.jymimaView);
        make.left.equalTo(self.jymimaView).with.offset(15);
        make.width.equalTo(@60);
    }];
    
    self.yanjingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.jymimaView addSubview:self.yanjingButton];
    [self.yanjingButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.jymimaView);
        make.right.equalTo(self.jymimaView).with.offset(-15);
        
    }];
    [self.yanjingButton setImage:[UIImage imageNamed:@"icon_biyan_h"] forState:UIControlStateNormal];
    [self.yanjingButton addTarget:self action:@selector(jymimaButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.jymimaTextField = [[UITextField alloc] init];
    [self.jymimaView addSubview:self.jymimaTextField];
    [self.jymimaTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.jymimaView);
        make.left.equalTo(jymiomaLabel.mas_right).with.offset(15);
        make.right.equalTo(self.yanjingButton.mas_left).with.offset(-15);
        
    }];
    self.jymimaTextField.secureTextEntry = YES;
    self.jymimaTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.jymimaTextField.placeholder =@"请输入交易密码";
    self.jymimaTextField.font = [UIFont systemFontOfSize:14.f];
    
    
}

- (void)yanzhengmaLoadView {
    
    UILabel * yanzhengmaLabel = [[UILabel alloc] init];
    yanzhengmaLabel.text = @"验证码";
    yanzhengmaLabel.font = [UIFont systemFontOfSize:14];
    [self.yanzhengmaView addSubview:yanzhengmaLabel];
    [yanzhengmaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.yanzhengmaView);
        make.left.equalTo(self.yanzhengmaView).with.offset(15);
        make.width.equalTo(@60);
    }];
    
    self.yanzhengmaButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.yanzhengmaView addSubview:self.yanzhengmaButton];
    [self.yanzhengmaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.yanzhengmaView);
        make.right.equalTo(self.yanzhengmaView).with.offset(-15);
        make.width.equalTo(@80);
        
    }];
    [self.yanzhengmaButton setTitle:@"发送验证码" forState:UIControlStateNormal];
    [self.yanzhengmaButton setTitleColor:[UIColor blueColor]forState:UIControlStateNormal];
    self.yanzhengmaButton.titleLabel.font = [UIFont systemFontOfSize: 15.0];
    [self.yanzhengmaButton addTarget:self action:@selector(yanzhengmaButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.yanzhengmaTextField = [[UITextField alloc] init];
    [self.yanzhengmaView addSubview:self.yanzhengmaTextField];
    [self.yanzhengmaTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.yanzhengmaView);
        make.left.equalTo(yanzhengmaLabel.mas_right).with.offset(15);
        make.right.equalTo(self.yanzhengmaButton.mas_left).with.offset(-15);
        
    }];
    self.yanzhengmaTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.yanzhengmaTextField.placeholder =@"请输入手机验证码";
    self.yanzhengmaTextField.font = [UIFont systemFontOfSize:14.f];
    
    
    
    
}


//隐藏密码
- (void)jymimaButtonAction:(UIButton *)sender {
    
    if (self.jymimaTextField.secureTextEntry == YES) {
        
        self.jymimaTextField.secureTextEntry = NO;
        [self.yanjingButton setImage:[UIImage imageNamed:@"icon_yangjingh"] forState:UIControlStateNormal];
    }else {
        self.jymimaTextField.secureTextEntry = YES;
        [self.yanjingButton setImage:[UIImage imageNamed:@"icon_biyan_h"] forState:UIControlStateNormal];
        
    }
    
    
}

//确认方法
- (void)querenButtonAction:(UIButton *)sender {
    
    
    
}

// 验证码
- (void)yanzhengmaButtonAction:(UIButton *)sender {
    
    
    
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.hidesBottomBarWhenPushed=YES;
    }
    return self;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
